package io;

import java.io.*;

// 利用PrintWriter 直接写入
public class Demo9 {
    public static void main(String[] args) throws IOException {
        try (OutputStream out = new FileOutputStream("Demo.txt")) {
            try (OutputStreamWriter osw = new OutputStreamWriter(out,"utf-8")) {
                try (PrintWriter writer = new PrintWriter(osw)) {
                    writer.println("Hello");
                    writer.print("你好");
                    writer.print("！世界！");
                    //清空缓存区
                    writer.flush();
                }
            }
        }

    }
}
